var app = getApp();
var WxParse = require('../../../wxParse/wxParse.js');
Page({
  data:{
    banner: [],
    news_list: [],
    sysinfo: {},
    pageid:1,
  },
  onShow:function(){
      swan.setPageInfo && swan.setPageInfo({
        title: '',
        keywords: '',
        description: '',
    })
  },
  onLoad:function(options){
    var that = this
    that.loadData(1)
    swan.request({
            url: app.util.url('s=bdxcx&c=home&m=index'), 
            method: 'GET',
            dataType: 'json',
            header: {
                'content-type': 'application/json' 
            },
            success: function (res) {
                //console.log(res);
                if (res.data.code) {
                    // 载入成功
                    that.setData({
                        banner: res.data.data.banner
                    }),
                    swan.setNavigationBarTitle({
                        title: res.data.data.name,
                    })
                    swan.setPageInfo && swan.setPageInfo({
                        title: res.data.data.seo.meta_title,
                        keywords: res.data.data.seo.meta_keywords,
                        description: res.data.data.seo.meta_description
                    })
                }
            }
    });
    

  },
  loadData: function (pageid) {
    var that = this
    swan.request({
                url: app.util.url('s=news&c=search&page='+pageid+'&pagesize=10&api_call_function=module_search_news_list'), 
                method: 'GET',
                dataType: 'json',
                header: {
                    'content-type': 'application/json' 
                },
                success: function (res) {
                    //console.log(res);
                    if (res.data.code) {
                        // 载入成功
                        var arr = that.data.news_list
                        var newarr = arr.concat(res.data.data);
                        that.setData({
                            news_list: newarr,
                            pageid: pageid
                        })
                    }
                }
        });
  },
  loadMore: function (event) {
    var id = event.currentTarget.dataset.pageid
    this.loadData(id + 1);
  },


  
})